from functools import wraps

from flask import abort
from flask_login import current_user
from flask_babel import _
from controllers.errors.error import HTTPNotLoginError, UnauthorizedAndForceLogout
from core.entities.account_role import AccountRole

# def backend_user(view):
#     @wraps(view)
#     def decorated(*args, **kwargs):
#         # check account initialization
#         account = current_user
#         if not account:
#             raise HTTPNotLoginError()
#         if not AccountRole.is_privileged_to_role(account.current_role,AccountRole.NORMAL_USER):
#             raise UnauthorizedAndForceLogout(_("You are not authorized to access this resource."))

#         return view(*args, **kwargs)

#     return decorated

def email_password_login_enabled(view):
    @wraps(view)
    def decorated(*args, **kwargs):
        
        if True:
            return view(*args, **kwargs)
        # otherwise, return 403
        abort(403)
    return decorated